<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>

<chiptrack:checkLogon sourcePage="/costCodeSetup.do"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<script language="javascript">       

 var newRowindex = 0;

function Save()
{
    var form = document.costCodeSetupForm;

    form.action="<%=chipTracContext%>/costCodeSetup.do?action=saveCostCodes";
    form.submit();
}

/*To reset the Values */
function Cancel()
{
    document.costCodeSetupForm.action = '<%=chipTracContext%>/costCodeSetup.do';
	document.costCodeSetupForm.submit();
}


function addMore()
{
        var tab = document.getElementById ("costCodeTable");
        var index = document.getElementById ("rowIndex").rowIndex;
        var newRow = tab.insertRow ( index );

        var newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
		newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].costCode" size=7 class="txfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].assy" size=7 class="txfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].base" size=7 class="txfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].pkg" size=7 class="txfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].pin" size=7 class="txfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].pkgDesc" size=7 class="txfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].waferCost" value="0.0" size=7 class="valuetxfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].dieCost" value="0.0" size=7 class="valuetxfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].assyCost" value="0.0" size=7 class="valuetxfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].testCost" value="0.0" size=7 class="valuetxfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].fgCost" value="0.0" size=7 class="valuetxfield">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor = "#DEE1E2";
        newCell.align = "center";
        var htmltext = '<input type="text" name="costCodeList['+newRowindex+'].trCost" value="0.0" size=7 class="valuetxfield">';
        newCell.innerHTML = htmltext;



        newRowindex++;
}

function ExportToExcel()
{
    var form = document.costCodeSetupForm;

    var year  = form.year.value;
    var quater = form.quater.value;
    var url = '<%=chipTracContext%>/operationsDataDumpReports.do?action=costCodesXlReport&popUp=true&year=' + year + '&quater=' + quater;

    newWindow = window.open ( url, 'costCodesXlReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');

}


</script>

</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@include file="/jsp/includes/header.jsp"  %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
 <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

	<!-- Side Navigation start -->
	<%@ include file="/jsp/finance/finance_menu.jsp" %>
	<!-- end of the side navigations -->
    </TD>
	<TD bgcolor="#ffffff">
        <IMG height="9" src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="8"></TD>
        <TD bgcolor="#ffffff"><IMG height=460 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="2"></TD>
        <TD valign="top" width="100%">
        <IMG height="1" src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width="500" border="0">
        <BR>
         <!-- BODY STARTS HERE -->
        <html:form name="costCodeSetupForm" type="com.scalar.chiptrack.finance.forms.CostCodeSetupForm"  action="/costCodeSetup.do">
            <table valign="top" width="100%" border="0" cellpadding="1" cellspacing="1" id = "costCodeTable">
                <tr><td colspan="12" width="100%" align="center"><center><span class="NArialW">Cost Code Setup </span></center></td></tr>
                <TR><TD colspan="12"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></TD></TR>
                <tr><td colspan="12" class='NArialL'><FONT id="errors" styleClass="NArialL" color="#FF0000"></FONT></td></tr>
                <tr><td colspan="12" id="svrErrors"><chiptrack:errors styleClass="NArialL"/></td></tr>
                <tr><td colspan="12" id="svrInfo"><chiptrack:info styleClass="NArialL"/></td></tr>
                <tr align = "center">
                      <td colspan="3"></td>
                      <td  align = "center" class="NArialL">Year:</td>
                      <td  align = "center" class="bodyText"><nested:write property="year"></nested:write></td>
                      <td></td>
                      <td  align = "center" class="NArialL">Quater:</td>
                      <td  align = "center" class="bodyText"><nested:write property="quater"></nested:write></td>
                      <td nowrap colspan="4" align = "center" class="NArialL" ><a href= "javascript:ExportToExcel();">Export To Excel</a> </td>
                </tr>

                <TR><TD colspan="12"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></TD></TR>

                <tr bgcolor="#993333" align = "center">

                    <td align = "center" class='NArialL'><font color="#FFFFFF">Cost Code</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">Assy</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">Base</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">PKG</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">PIN</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">Pkg Desc</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">Wafer Cost</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">Die Cost</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">Assm Cost</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">Test Cost</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">FG Cost</font></td>
                    <td align = "center" class='NArialL'><font color="#FFFFFF">T&R Cost</font></td>
                </tr>

                <nested:size id="ListSize" property="costCodeList" />
                <script type="text/javascript" >
                    newRowindex = <%= ListSize.intValue() %>;
                </script>
                <logic:greaterThan name="ListSize" value="0">

                <nested:iterate id="costCodeInfo" indexId="iterateIdx" property="costCodeList" >

                <tr bgcolor='#DEE1E2'>
                    <nested:hidden property ="costCodeId"/>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "txfield" size = "7" property ="costCode"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "txfield" size = "7" property ="assy"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "txfield" size = "7" property ="base"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "txfield" size = "7" property ="pkg"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "txfield" size = "7" property ="pin"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "txfield" size = "7" property ="pkgDesc"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "valuetxfield" size = "7" property ="waferCost"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "valuetxfield" size = "7" property ="dieCost"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "valuetxfield" size = "7" property ="assyCost"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "valuetxfield" size = "7" property ="testCost"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "valuetxfield" size = "7" property ="fgCost"/></td>
                    <td align = "center" class='NArialL'><nested:text name="costCodeInfo" styleClass = "valuetxfield" size = "7" property ="trCost"/></td>

                </tr>
                 </nested:iterate>
         </logic:greaterThan>
         <tr id="rowIndex"><td colspan='13' >&nbsp;<FONT id="font1"></FONT></TD></TR>
         <TR><TD colspan="12" width="90%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></TD></TR>
         <TR><TD align=right colspan=12><a href="javascript:addMore();"><img src="<%=chipTracContext%>/jsp/includes/images/addmore.gif" border="0" onmouseover="window.status='Click to Add Cost Codes';return true" onmouseout="window.status='';return true" title="Click here to Add Cost Codes"/></a></TD></TR>
         <nested:hidden property="year" ></nested:hidden>
         <nested:hidden property="quater" ></nested:hidden>
        <tr>
            <td colspan= 4></td>
           <td align="center" colspan=2 >
                <a href="javascript:Save()" onmouseover="window.status='Click here to Save Cost Codes';return true" onmouseout="window.status='';return true" title="Click here to save Cost Codes"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></a>
           </td>
           <td align="center" colspan=2 >
                <a href="javascript:Cancel()" onmouseover="window.status='Click here to Cancel Cost Setup';return true" onmouseout="window.status='';return true" title="Click here to Cancel Cost Setup"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width="53" height="17"></a>
           </td>
           <td colspan= 4></td>
        </tr>
 </table>
</html:form>
<!-- End : Report Block -->
<BR><BR><BR>
</TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>
